package com.example.mvvmdemo.api;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author: tuyrt7 on 2020/8/31.
 * Describe:
 */
public class RetrofitClient {

    public static final String BASE_USL = "https://api.github.com/";

    private static RetrofitClient sRetrofitClient;
    private Retrofit mRetrofit;

    private RetrofitClient() {
        mRetrofit = new Retrofit.Builder()
                .baseUrl(BASE_USL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public static synchronized RetrofitClient get() {
        if (sRetrofitClient == null) {
            sRetrofitClient = new RetrofitClient();
        }
        return sRetrofitClient;
    }


    public Api getApi() {
        return mRetrofit.create(Api.class);
    }
}
